package com.matt.domain.mp;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.matt.commons.model.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.util.Date;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2017/7/18
 * *******************************
 */
@Entity
@Data
@Table(name = "users", uniqueConstraints = {@UniqueConstraint(columnNames = "phone")})
@EqualsAndHashCode(callSuper = true)
public class ParentUser extends Model {

    @Column
    private String name;

    @Column
    private String phone;

    @Column(name = "pwd")
    private String password;

    @Column
    private String company;

    @Column
    private String email;

    @Column
    private Integer status = 0;

    @Column(name = "ext")
    private String extension = "";

    @Column(name = "createTime")
    private Date created = new Date();


    //////// switch for params begin
    @Transient
    @JsonIgnore
    private Boolean cameraEnabled = true;

    @Transient
    @JsonIgnore
    private Boolean wechatEnabled = true;

    @Transient
    @JsonIgnore
    private Boolean templateMsgEnabled = true;

    @Transient
    @JsonIgnore
    private Boolean teacherChatEnabled = true;
    //////// switch for params end

    @Transient
    private String relation;

    @Transient
    private String remark;

    @Transient
    private String rid;

    @Column(columnDefinition = "varchar(255) COMMENT '头像' ")
    private String headImgUrl;

    @Column
    private String province;

    @Column
    private String city;

    @Column
    private String district;

    @Column
    private String detailedAddress;

    @Column
    private String education;

    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date birthDay;
    @Column
    private String position;
    @Column(columnDefinition = "int default 0 COMMENT ' 联系人类型（1.第一联系人,2.第二联系人,3.第三联系人）'")
    private Integer type ;

    public static ParentUser of(String name, String phone, String company,String province,String city,String district,String detailedAddress,String education,String position,String email){
        ParentUser parentUser = new ParentUser();
        parentUser.setName(name);
        parentUser.setPhone(phone);
        parentUser.setCompany(company);
        parentUser.setProvince(province);
        parentUser.setCity(city);
        parentUser.setDistrict(district);
        parentUser.setDetailedAddress(detailedAddress);
        parentUser.setEducation(education);
        parentUser.setPosition(position);
        parentUser.setEmail(email);
        return parentUser;
    }
    public static ParentUser of1(String name, String phone, String company,String province,String city,String district,String detailedAddress,String education,String position,String email,Date birthDay){
        ParentUser parentUser = new ParentUser();
        parentUser.setName(name);
        parentUser.setPhone(phone);
        parentUser.setCompany(company);
        parentUser.setProvince(province);
        parentUser.setCity(city);
        parentUser.setDistrict(district);
        parentUser.setDetailedAddress(detailedAddress);
        parentUser.setEducation(education);
        parentUser.setPosition(position);
        parentUser.setEmail(email);
        parentUser.setBirthDay(birthDay);
        return parentUser;
    }
}
